﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B303Langf.Scanner
{
    public class Token
    {
       public Token( TokenKind kind, string spelling )
       {
          Kind = kind;
          Spelling = spelling;

          if( kind == TokenKind.Identifier )
          {
             TokenKind newKind;
             if( Keywords.Spellings.TryGetValue( spelling, out newKind ) )
             {
                Kind = newKind;
             }
          }
       }

       public TokenKind Kind
       {
          get;
          private set;
       }

       public string Spelling
       {
          get;
          private set;
       }

       public override string ToString()
       {
          return "{" + Kind.ToString() + ", " + Spelling + "}";
       }
    }
}
